﻿using System.Windows;
using System.Windows.Controls;

namespace TextEditor
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private DocumentManager documentManager;

        public MainWindow()
        {
            InitializeComponent();
            documentManager = new DocumentManager(body);
            if (documentManager.OpenDocument()) status.Text = "Document loaded.";
        }

        private void TextEditorToolbar_SelectionChanged(object sender,SelectionChangedEventArgs e)
        {
            ComboBox source = e.OriginalSource as ComboBox;
            if (source == null) return;
            switch (source.Name)
            {
            case "fonts":
                documentManager.ApplyToSelection(TextBlock.FontFamilyProperty,source.SelectedItem);
                break;
            case "fontSize":
                documentManager.ApplyToSelection(TextBlock.FontSizeProperty, source.SelectedItem);
                break;
            }
            body.Focus();
        }
    }
}
